home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11194 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: EU.net!sun4nl!xs4all!falstaff
  2. From: falstaff@xs4all.nl (Falstaff)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: given: char foo[80]; there is no such thing as element foo[80] correct? (i.e. foo[80] = '\0' is beyond the array boundary)
  5. Date: 22 Mar 1996 14:04:57 GMT
  6. Organization: XS4ALL, networking for the masses
  7. Message-ID: <4iuc29$1ma@news.xs4all.nl>
  8. References: <314ad16d.86316693@news> <1996Mar16.175143.10948@zcon.com> <4ithke$mql@hermes.acs.unt.edu>
  9. NNTP-Posting-Host: xs1.xs4all.nl
  10. X-Newsreader: NN version 6.5.0 #666 (NOV)
  11.  
  12. johnw@jove.acs.unt.edu (John R. Williams) writes:
  13.  
  14. >Syed Zaeem Hosain (szh@zcon.com) wrote:
  15. >> >// Yes. This works nice and safely for any array of known size.
  16. >> >foo[sizeof(foo)-1] = '\0';
  17.  
  18. >This is not safe even for strings if your character type is not 
  19. >'char'. I know that sounds silly, but wchar_t *is* there for a reason, 
  20. >y'know.
  21.  
  22. John means that some compilers may choose to make wchar_t a short,
  23. and support Unicode.  Of course, they would need to implement all
  24. string operations for normal and wide strings (no such thing as
  25. strlen() defined for wide strings in ANSI).
  26.  
  27. Frank
  28. --
  29. The famous GIICM now on line:  http://www.xs4all.nl/~falstaff/GIICM.html
  30. ------------------------------------------------------------------------
  31. Frank A. Vorstenbosch        +31-(70)-355 5241        falstaff@xs4all.nl
  32.